package com.lwj.liwanjia.utils;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.view.activity.indent.UnpaidActivity;

/**
 * Created by Administrator on 2017/9/15.
 */

public class CancleDialog extends Dialog implements View.OnClickListener {
    private Context context;
    private TextView tvContinue;
    private String type;

    public CancleDialog(@NonNull Context context, String type) {
        super(context, R.style.MyDialog);
        this.type = type;
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cancle_pay_layout);
        initView();
    }

    private void initView() {
        Window window = getWindow();
        window.setGravity(Gravity.CENTER);
        window.setWindowAnimations(R.style.dialog_animation);
        setCanceledOnTouchOutside(false);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = params.WRAP_CONTENT;
        params.height = params.WRAP_CONTENT;
        window.setAttributes(params);
        tvContinue = (TextView) findViewById(R.id.tv_continue);
        TextView tvLeave = (TextView) findViewById(R.id.tv_leave);
        TextView tvAsk = (TextView) findViewById(R.id.tv_ask);
        if (type.equals("待付款") || type.equals("订单取消")) {
            tvAsk.setText("是否删除订单？");
        } else if (type.equals("待发货")) {
            tvAsk.setText("是否申请退款？");
        } else if (type.equals("退款")) {
            tvAsk.setText("是否取消退货、退款？");
        } else if (type.equals("删除") || type.equals("上架") || type.equals("下架")) {//发布删除、上下架商品
            tvAsk.setText("是否" + type + "商品？");
        } else {
            tvAsk.setText("是否删除订单");
        }
        tvContinue.setText("确定");
        tvLeave.setText("取消");
        tvContinue.setOnClickListener(this);
        tvLeave.setOnClickListener(this);

    }

    public TextView getSure() {
        return tvContinue;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_leave://取消
                dismiss();
                break;
        }
    }
}
